var o = require("../../utils/config.js");

getApp();

Page({
    data: {
        mobile: "",
        code: ""
    },
    onLoad: function(o) {},
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    goToXieYi: function() {
        wx.navigateTo({
            url: "../web/web?src=https://www.xiangyaowant.com/serviceInfo.html"
        });
    },
    goToXieYi2: function() {
        wx.navigateTo({
            url: "../web/web?src=https://www.xiangyaowant.com/gxjj.html"
        });
    },
    goToXieYi3: function() {
        wx.navigateTo({
            url: "../web/web?src=https://www.xiangyaowant.com/grjjzywcbxy.html"
        });
    },
    goToRegist: function() {
        wx.navigateTo({
            url: "regist"
        });
    },
    getMobile: function(o) {
        this.setData({
            mobile: o.detail.value
        });
    },
    getCode: function(o) {
        this.setData({
            code: o.detail.value
        });
    },
    login: function(t) {
        var e = this;
        e.data.mobile ? e.data.code ? (wx.showLoading({
            mask: !0
        }), wx.login({
            success: function(a) {
                console.log({
                    mobile: e.data.mobile,
                    verificationCode: e.data.code,
                    code: a.code
                }), wx.request({
                    url: o.urlList.API_USER_LOGIN,
                    method: "POST",
                    data: {
                        mobile: e.data.mobile,
                        verificationCode: e.data.code,
                        code: a.code
                    },
                    header: {
                        "content-type": "application/json"
                    },
                    success: function(o) {
                        wx.hideLoading(), 200 == o.data.status || 412 == o.data.status ? (wx.setStorage({
                            key: "userId",
                            data: o.data.data.userId
                        }), wx.setStorage({
                            key: "mobile",
                            data: o.data.data.mobile
                        }), wx.setStorage({
                            key: "userInfo",
                            data: t.detail.userInfo
                        }), wx.navigateBack()) : wx.showToast({
                            title: o.data.message,
                            icon: "none"
                        });
                    }
                });
            }
        })) : wx.showToast({
            title: "请输入验证码",
            icon: "none"
        }) : wx.showToast({
            title: "请输入手机号",
            icon: "none"
        });
    },
    goToForgetPassword: function() {
        wx.navigateTo({
            url: "forgetPassword"
        });
    }
});